package com.github.glideplus;

import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.bumptech.glide.load.Transformation;
import com.bumptech.glide.load.engine.Resource;
import com.bumptech.glide.load.resource.bitmap.BitmapResource;
import com.github.glideplus.impl.GlideLoader;
import com.github.glideplus.impl.DisplayOptions;



/**
 * Created by zoudong on 2017/2/19.
 */

public class ImageLoader {

    private  static class Signle {
        private static ImageLoader imageLoader = new ImageLoader();
    }
   public  static ImageLoader getInstance(){
        return  Signle.imageLoader;
   }
    public void displayImage(Context context, String url, ImageView imageView) {
        GlideLoader.with(context).load(url).build(DisplayOptions.defaultOptions().build()).into(imageView);
    }

    public void displayCircleImage(Context context, String url, ImageView imageView) {
        GlideLoader.with(context).load(url).build(DisplayOptions.defaultOptions().cropCircle().build()).into(imageView);
    }
    public void displayRoundImage(Context context, String url,  int rounded_Radius, int rounded_Margin, ImageView imageView) {
        displayRoundImage(context, url,rounded_Radius, rounded_Margin, imageView, DisplayOptions.RoundModel.CornerType.ALL);

    }
    public void displayRoundImage(Context context, String url, int rounded_Radius, int rounded_Margin, ImageView imageView,DisplayOptions.RoundModel.CornerType cornerType) {
        GlideLoader.with(context).load(url).build(DisplayOptions.defaultOptions()
                .roundCorners(new DisplayOptions.RoundModel(cornerType, rounded_Radius, rounded_Margin))
                .build()
        ).into(imageView);
    }

    public void displayImage(Context context, String url, ImageView imageView, DisplayOptions builder) {
        GlideLoader.with(context).load(url).build(builder).into(imageView);
    }

}
